/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.cggveritas.crewintranet.jms.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.codehaus.jackson.annotate.JsonIgnore;

/**
 *
 * @author Alassane
 */
@Entity
@Table(name = "cv_affectation")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CvAffectation.findAll", query = "SELECT c FROM CvAffectation c"),
    @NamedQuery(name = "CvAffectation.findByIdaffectation", query = "SELECT c FROM CvAffectation c WHERE c.idaffectation = :idaffectation"),
    @NamedQuery(name = "CvAffectation.findByDateaffectation", query = "SELECT c FROM CvAffectation c WHERE c.dateaffectation = :dateaffectation")})
public class CvAffectation implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idaffectation")
    private Integer idaffectation;
    @Basic(optional = false)
    @Column(name = "dateaffectation")
    @Temporal(TemporalType.DATE)
    private Date dateaffectation;
    @OneToMany(mappedBy = "cvAffectationIdaffectation", fetch = FetchType.LAZY)
    private List<CvTravailleur> cvTravailleurList;
    @JoinColumn(name = "cv_equipedepartement_idequipedepartement", referencedColumnName = "idequipedepartement")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private CvEquipedepartement cvEquipedepartementIdequipedepartement;

    public CvAffectation() {
    }

    public CvAffectation(Integer idaffectation) {
        this.idaffectation = idaffectation;
    }

    public CvAffectation(Integer idaffectation, Date dateaffectation) {
        this.idaffectation = idaffectation;
        this.dateaffectation = dateaffectation;
    }

    public Integer getIdaffectation() {
        return idaffectation;
    }

    public void setIdaffectation(Integer idaffectation) {
        this.idaffectation = idaffectation;
    }

    public Date getDateaffectation() {
        return dateaffectation;
    }

    public void setDateaffectation(Date dateaffectation) {
        this.dateaffectation = dateaffectation;
    }

    @XmlTransient
    @JsonIgnore
    public List<CvTravailleur> getCvTravailleurList() {
        return cvTravailleurList;
    }

    public void setCvTravailleurList(List<CvTravailleur> cvTravailleurList) {
        this.cvTravailleurList = cvTravailleurList;
    }

    public CvEquipedepartement getCvEquipedepartementIdequipedepartement() {
        return cvEquipedepartementIdequipedepartement;
    }

    public void setCvEquipedepartementIdequipedepartement(CvEquipedepartement cvEquipedepartementIdequipedepartement) {
        this.cvEquipedepartementIdequipedepartement = cvEquipedepartementIdequipedepartement;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idaffectation != null ? idaffectation.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CvAffectation)) {
            return false;
        }
        CvAffectation other = (CvAffectation) object;
        if ((this.idaffectation == null && other.idaffectation != null) || (this.idaffectation != null && !this.idaffectation.equals(other.idaffectation))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.cggveritas.crewintranet.jms.entities.CvAffectation[ idaffectation=" + idaffectation + " ]";
    }
    
}
